//### This file created by BYACC 1.8(/Java extension  1.15)
//### Java capabilities added 7 Jan 97, Bob Jamison
//### Updated : 27 Nov 97  -- Bob Jamison, Joe Nieten
//###           01 Jan 98  -- Bob Jamison -- fixed generic semantic constructor
//###           01 Jun 99  -- Bob Jamison -- added Runnable support
//###           06 Aug 00  -- Bob Jamison -- made state variables class-global
//###           03 Jan 01  -- Bob Jamison -- improved flags, tracing
//###           16 May 01  -- Bob Jamison -- added custom stack sizing
//###           04 Mar 02  -- Yuval Oren  -- improved java performance, added options
//###           14 Mar 02  -- Tomas Hurka -- -d support, static initializer workaround
//### Please send bug reports to tom@hukatronic.cz
//### static char yysccsid[] = "@(#)yaccpar	1.8 (Berkeley) 01/20/90";






//#line 2 "nudroid.y"
package pkg.nudroid.translator;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
//#line 22 "Parser.java"




public class Parser
{

boolean yydebug;        //do I want debug output?
int yynerrs;            //number of errors so far
int yyerrflag;          //was there an error?
int yychar;             //the current working character

//########## MESSAGES ##########
//###############################################################
// method: debug
//###############################################################
void debug(String msg)
{
  if (yydebug)
    System.out.println(msg);
}

//########## STATE STACK ##########
final static int YYSTACKSIZE = 500;  //maximum stack size
int statestk[] = new int[YYSTACKSIZE]; //state stack
int stateptr;
int stateptrmax;                     //highest index of stackptr
int statemax;                        //state when highest index reached
//###############################################################
// methods: state stack push,pop,drop,peek
//###############################################################
final void state_push(int state)
{
  try {
		stateptr++;
		statestk[stateptr]=state;
	 }
	 catch (ArrayIndexOutOfBoundsException e) {
     int oldsize = statestk.length;
     int newsize = oldsize * 2;
     int[] newstack = new int[newsize];
     System.arraycopy(statestk,0,newstack,0,oldsize);
     statestk = newstack;
     statestk[stateptr]=state;
  }
}
final int state_pop()
{
  return statestk[stateptr--];
}
final void state_drop(int cnt)
{
  stateptr -= cnt; 
}
final int state_peek(int relative)
{
  return statestk[stateptr-relative];
}
//###############################################################
// method: init_stacks : allocate and prepare stacks
//###############################################################
final boolean init_stacks()
{
  stateptr = -1;
  val_init();
  return true;
}
//###############################################################
// method: dump_stacks : show n levels of the stacks
//###############################################################
void dump_stacks(int count)
{
int i;
  System.out.println("=index==state====value=     s:"+stateptr+"  v:"+valptr);
  for (i=0;i<count;i++)
    System.out.println(" "+i+"    "+statestk[i]+"      "+valstk[i]);
  System.out.println("======================");
}


//########## SEMANTIC VALUES ##########
//public class ParserVal is defined in ParserVal.java


String   yytext;//user variable to return contextual strings
ParserVal yyval; //used to return semantic vals from action routines
ParserVal yylval;//the 'lval' (result) I got from yylex()
ParserVal valstk[];
int valptr;
//###############################################################
// methods: value stack push,pop,drop,peek.
//###############################################################
void val_init()
{
  valstk=new ParserVal[YYSTACKSIZE];
  yyval=new ParserVal();
  yylval=new ParserVal();
  valptr=-1;
}
void val_push(ParserVal val)
{
  if (valptr>=YYSTACKSIZE)
    return;
  valstk[++valptr]=val;
}
ParserVal val_pop()
{
  if (valptr<0)
    return new ParserVal();
  return valstk[valptr--];
}
void val_drop(int cnt)
{
int ptr;
  ptr=valptr-cnt;
  if (ptr<0)
    return;
  valptr = ptr;
}
ParserVal val_peek(int relative)
{
int ptr;
  ptr=valptr-relative;
  if (ptr<0)
    return new ParserVal();
  return valstk[ptr];
}
final ParserVal dup_yyval(ParserVal val)
{
  ParserVal dup = new ParserVal();
  dup.ival = val.ival;
  dup.dval = val.dval;
  dup.sval = val.sval;
  dup.obj = val.obj;
  return dup;
}
//#### end semantic value section ####
public final static short IDENTIFIER=257;
public final static short NAME=258;
public final static short NUMBER=259;
public final static short STRING=260;
public final static short UNFORMATTED_STRING=261;
public final static short T_NUDROID=262;
public final static short CT_NUDROID=263;
public final static short T_NAVIGATION=264;
public final static short CT_NAVIGATION=265;
public final static short T_STYLE=266;
public final static short CT_STYLE=267;
public final static short T_PAGE=268;
public final static short CT_PAGE=269;
public final static short T_TEXT=270;
public final static short CT_TEXT=271;
public final static short T_INPUT=272;
public final static short CT_INPUT=273;
public final static short T_LINK=274;
public final static short CT_LINK=275;
public final static short T_IMAGE=276;
public final static short CT_IMAGE=277;
public final static short T_LIST=278;
public final static short CT_LIST=279;
public final static short T_TABLE=280;
public final static short CT_TABLE=281;
public final static short T_AUDIO=282;
public final static short CT_AUDIO=283;
public final static short T_VIDEO=284;
public final static short CT_VIDEO=285;
public final static short T_BUTTON=286;
public final static short CT_BUTTON=287;
public final static short T_FUNCTION=288;
public final static short CT_FUNCTION=289;
public final static short T_VAR=290;
public final static short CT_VAR=291;
public final static short T_GOTO=292;
public final static short T_SETVAR=293;
public final static short T_GETVAR=294;
public final static short T_GETINPUT=295;
public final static short T_GETTEXT=296;
public final static short T_SETTEXT=297;
public final static short T_LOOP=298;
public final static short CT_LOOP=299;
public final static short T_TEST=300;
public final static short CT_TEST=301;
public final static short T_TRUE=302;
public final static short CT_TRUE=303;
public final static short T_FALSE=304;
public final static short CT_FALSE=305;
public final static short CT_SELF_CLOSING=306;
public final static short CT_SETTEXT=307;
public final static short T_MENU=308;
public final static short CT_MENU=309;
public final static short B_TRUE=310;
public final static short B_FALSE=311;
public final static short P_NAME=312;
public final static short P_PAGEID=313;
public final static short P_URL=314;
public final static short P_EMAIL=315;
public final static short P_BULLET_STYLE=316;
public final static short P_TYPE=317;
public final static short P_COLS=318;
public final static short P_FUNCTIONID=319;
public final static short P_VALUE=320;
public final static short P_CONDITION=321;
public final static short P_START=322;
public final static short P_END=323;
public final static short P_ID=324;
public final static short P_LABEL=325;
public final static short P_STYLEID=326;
public final static short P_POSITION=327;
public final static short P_HEIGHT=328;
public final static short P_WIDTH=329;
public final static short P_LOCATION=330;
public final static short P_SIZE=331;
public final static short P_COLOR=332;
public final static short P_FONT=333;
public final static short P_LORIENTATION=334;
public final static short P_VARID=335;
public final static short P_TEXTID=336;
public final static short P_INPUTID=337;
public final static short P_TEXT=338;
public final static short FONT_SERIF=339;
public final static short FONT_SANS=340;
public final static short FONT_MONO=341;
public final static short BULLET_NUMBERS=342;
public final static short BULLET_ATOZ_UPPER=343;
public final static short BULLET_ATOZ_LOWER=344;
public final static short BULLET_CIRCLES=345;
public final static short BULLET_SQUARES=346;
public final static short BULLET_DISCS=347;
public final static short LIST_VERTICAL=348;
public final static short LIST_HORIZONTAL=349;
public final static short TYPE_NUMBER=350;
public final static short TYPE_STRING=351;
public final static short LOGIC_OR=352;
public final static short LOGIC_AND=353;
public final static short RELOP_EQ=354;
public final static short RELOP_NEQ=355;
public final static short RELOP_GEQ=356;
public final static short RELOP_LEQ=357;
public final static short POSITION_TOP=358;
public final static short POSITION_BOTTOM=359;
public final static short POSITION_LEFT=360;
public final static short POSITION_RIGHT=361;
public final static short POSITION_CENTER=362;
public final static short ORIENTATION_VERTICAL=363;
public final static short ORIENTATION_HORIZONTAL=364;
public final static short YYERRCODE=256;
final static short yylhs[] = {                           -1,
    0,    3,    3,    4,    4,    1,    2,    2,    7,    7,
    8,    9,    5,   14,   14,   15,   15,   15,   15,   15,
   15,   15,   15,   15,   15,   13,   13,   26,   16,   17,
   25,   29,   29,   11,   30,   31,   18,   18,   32,   32,
   33,   33,   33,   33,   19,   37,   37,   39,   38,   38,
   41,   41,   41,   40,   20,   42,   43,   43,   44,   44,
   44,   23,   45,   45,   46,   46,   24,   48,   48,   49,
   49,   21,    6,   51,   53,   53,   50,   50,   22,   22,
   22,   22,   22,   22,   22,   22,   54,   55,   56,   57,
   58,   59,   52,   52,   52,   65,   65,   65,   66,   66,
   67,   67,   67,   67,   68,   68,   68,   68,   68,   68,
   68,   69,   69,   69,   69,   69,   69,   60,   70,   71,
   61,   10,   62,   64,   63,   27,   36,   47,   47,   34,
   35,   28,   28,   28,   28,   28,   28,   12,   12,
};
final static short yylen[] = {                            2,
    6,    0,    2,    1,    1,    2,    0,    4,    0,    2,
    1,    6,    6,    0,    2,    1,    1,    1,    1,    1,
    1,    1,    1,    1,    1,    0,    2,    1,    5,    5,
    6,    1,    1,    2,    2,    2,    6,    4,    0,    2,
    1,    1,    1,    1,    6,    0,    2,    1,    0,    2,
    1,    1,    1,    2,    6,    2,    0,    2,    1,    1,
    1,    6,    0,    2,    1,    1,    6,    0,    2,    1,
    1,    6,    4,    2,    1,    2,    0,    1,    1,    1,
    1,    1,    1,    1,    1,    1,    3,    4,    3,    3,
    3,    5,    3,    3,    1,    3,    3,    1,    3,    1,
    1,    1,    1,    1,    3,    3,    2,    3,    3,    1,
    1,    1,    1,    1,    1,    1,    1,    7,    4,    4,
    8,    2,    2,    2,    2,    2,    2,    1,    1,    2,
    2,    0,    2,    2,    2,    2,    2,    0,    1,
};
final static short yydefred[] = {                         0,
    0,    0,    0,    0,    6,    0,    0,    2,    9,    0,
    0,    1,    0,    0,    3,    4,    5,    8,    0,   10,
   11,    0,   26,    0,    0,  122,    0,    0,    0,    0,
    0,    0,   14,   27,   28,  104,  101,    0,    0,    0,
    0,  102,  103,    0,   98,  100,   73,   34,    0,  126,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  139,    0,   13,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,   15,   16,
   17,   18,   19,   20,   21,   22,   23,   24,   25,   79,
   80,   81,   82,   83,   84,   85,   86,  123,   89,  125,
   90,   99,    0,    0,   96,   97,   12,    0,    0,    0,
   39,   46,    0,   63,   68,    0,    0,    0,    0,    0,
    0,    0,    0,  132,    0,    0,    0,    0,   32,   33,
    0,    0,    0,    0,    0,    0,    0,   87,    0,  124,
   91,  132,    0,  110,  111,    0,    0,    0,    0,    0,
    0,   35,   36,    0,   38,    0,    0,    0,  132,   43,
   40,   41,   42,   44,    0,   49,   47,   48,   56,   57,
  132,   66,  129,  128,   64,   65,  132,   71,   70,   69,
    0,   88,    0,    0,  107,    0,    0,  114,  117,  115,
  116,  113,  112,    0,    0,    0,    0,  133,   29,  134,
  135,  136,  137,   30,    0,  127,  130,  131,    0,   54,
    0,    0,    0,    0,   75,    0,    0,   92,    0,  108,
    0,    0,  106,    0,    0,   31,   37,   45,   51,   52,
   53,   50,   55,   59,   61,   60,   58,   62,   67,   72,
   76,    0,    0,    0,    0,    0,    0,    0,  118,  121,
  119,    0,  120,
};
final static short yydgoto[] = {                          2,
    4,    8,   10,   15,   16,   17,   11,   20,   21,   23,
   31,   62,   27,   51,   79,   80,   81,   82,   83,   84,
   85,  215,   87,   88,  200,   34,   35,  150,  128,  129,
  130,  131,  161,  173,  174,  164,  132,  211,  167,  168,
  232,  134,  212,  237,  135,  175,  176,  136,  180,  216,
   29,  148,  217,   90,   91,   42,   43,   94,   95,   96,
   97,   53,   55,  120,   44,   45,   46,  149,  194,  225,
  245,
};
final static short yysindex[] = {                      -212,
 -256,    0, -197,    4,    0, -192,   65,    0,    0, -211,
 -217,    0, -190, -190,    0,    0,    0,    0, -190,    0,
    0, -120,    0, -178, -165,    0,  -47,  -27, -153,  -99,
  101,  -93,    0,    0,    0,    0,    0, -154, -155,  -27,
   37,    0,    0,   16,    0,    0,    0,    0,  -77,    0,
   93,  -72, -119,  -69, -116,   83,  -27,  -27,  -27,  -27,
    0, -123,    0, -190, -190, -190, -190, -190, -190, -190,
 -190, -190, -165, -154, -143, -143, -128, -126,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,   16,   16,    0,    0,    0,  136,  137, -222,
    0,    0, -115,    0,    0, -118, -104, -178,  -51,  -96,
  149,  -27,   50,    0,  -77,  -48,  -45,  151,    0,    0,
  -55,  -26,  -43,  155,  -53,  -33,  156,    0,  -87,    0,
    0,    0,  -40,    0,    0,   50,   50,  -19,  -61, -210,
  -52,    0,    0,  -77,    0,  -38,  -39,  -36,    0,    0,
    0,    0,    0,    0,  -32,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 -124,    0, -219,  -27,    0,  -23,  -11,    0,    0,    0,
    0,    0,    0,  -27,   50,   50,  -78,    0,    0,    0,
    0,    0,    0,    0,  -42,    0,    0,    0, -196,    0,
 -156, -138, -144, -139,    0,  -60, -124,    0,   25,    0,
   37, -117,    0,  167,  -70,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0, -124, -124,  173,  -64,  -59,  -65, -124,    0,    0,
    0,  -66,    0,
};
final static short yyrindex[] = {                         0,
    0,    0,    0,    0,    0, -201,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  -63,    0,    0,  -41,    0,    0,    0,    0,  -68,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,  -35,  -29,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,  -31,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,  -30,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  -37,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0, -184,    0,    0,    0,
  -13,   -9,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,  -50,  -57,    0,    0,    0,    0,  -58,    0,    0,
    0,    0,    0,
};
final static short yygindex[] = {                         0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,   40,
  171, -114,    0,    0,    0,  -71,    0,  -67,    0,    0,
    0,  -28,    0,    0,   -7,    0,  132,  -46,    0,  -62,
    0,    0,    0,  121,  122,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,  119,    0,    0,  -83,
  138,    7,    0,    0,    0,  -34,  -17, -112,    0,    0,
    0,  180,    0,  181,  104,  118,    0, -101,    0,    0,
    0,
};
final static int YYTABLESIZE=393;
static short yytable[];
static { yytable();}
static void yytable(){
yytable = new short[]{                         95,
  197,   95,   57,   95,   58,   93,  159,   93,  171,   93,
  151,   94,   40,   94,   33,   94,   92,  102,   95,   57,
   95,   58,   86,   57,   93,   58,   93,  109,  177,  220,
   94,  105,   94,   93,   41,  166,  193,  203,  192,  205,
  193,  198,  192,   89,  185,  187,   56,   18,  109,    1,
  198,   12,  105,   24,   66,    3,   13,   59,   25,    5,
  199,    7,   60,   66,  198,    6,    7,   57,  160,   58,
  203,    7,  172,  178,   38,   39,   75,   66,   14,   57,
  227,   58,  146,   38,   39,   75,  242,  218,    7,  147,
   19,  126,  127,  222,  223,  183,  203,   38,   39,   75,
  203,  203,   78,  108,  109,  110,  111,  112,  113,  114,
  115,  116,  209,   64,   78,  201,  198,   66,   78,   67,
   78,  198,  228,  102,  213,   57,    9,   58,  143,   66,
  214,   64,  202,   22,   66,   66,   26,   67,  238,  229,
  234,   28,  233,  230,  235,  239,   92,   30,  201,   38,
   39,   75,   47,  186,   38,   39,   75,   48,  246,  247,
  103,  104,   49,   93,  252,  202,   50,   73,   74,   38,
   39,   75,   76,   77,  201,   78,  105,  106,  201,  201,
   52,   54,   92,   61,   98,  107,   99,  100,  241,  101,
  219,  202,  119,  122,  123,  202,  202,  124,  125,   93,
  221,  138,  133,  231,  236,  140,   32,   92,   92,  141,
  142,  152,  154,   92,  153,  169,  170,  181,  182,  207,
  204,  206,  208,  224,   93,   93,  240,  210,  243,   36,
   93,   37,  226,  244,  248,  196,  249,  251,  253,  250,
  138,  138,   74,  117,  138,   77,   77,  137,   77,   77,
  155,  162,  163,  118,  179,  139,  121,    0,  126,    0,
  126,    0,    0,    0,   95,    0,   38,   39,    0,    0,
   93,  156,  157,  158,  157,  158,   94,   32,    0,    0,
  126,   95,  184,    0,    0,    0,    0,   93,    0,  165,
  195,  196,    0,   94,  157,  158,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,   36,    0,   37,    0,
   95,   95,   95,   95,   95,   95,   93,   93,   93,   93,
   93,   93,   94,   94,   94,   94,   94,   94,    0,    0,
  188,  189,  190,  191,  188,  189,  190,  191,  109,  109,
  195,  196,  105,   38,   39,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,  144,
  145,   63,   64,    0,   65,    0,   66,    0,   67,    0,
   68,    0,   69,    0,   70,    0,   71,    0,   72,    0,
    0,    0,    0,    0,   73,   74,   38,   39,   75,   76,
   77,    0,   78,
};
}
static short yycheck[];
static { yycheck(); }
static void yycheck() {
yycheck = new short[] {                         41,
   62,   43,   43,   45,   45,   41,   62,   43,   62,   45,
  125,   41,   40,   43,   62,   45,   51,   41,   60,   43,
   62,   45,   51,   43,   60,   45,   62,   41,   62,   41,
   60,   41,   62,   51,   28,   62,   60,  150,   62,  154,
   60,  261,   62,   51,  146,  147,   40,  265,   62,  262,
  261,  263,   62,   14,  274,  312,  268,   42,   19,  257,
  271,  263,   47,  274,  261,   62,  268,   43,  131,   45,
  183,  264,  135,  136,  294,  295,  296,  274,  290,   43,
  277,   45,   33,  294,  295,  296,   62,  307,  290,   40,
  308,  314,  315,  195,  196,  142,  209,  294,  295,  296,
  213,  214,  287,   64,   65,   66,   67,   68,   69,   70,
   71,   72,  159,  270,  299,  150,  261,  274,  303,  276,
  305,  261,  279,   41,  171,   43,   62,   45,  122,  274,
  177,  270,  150,  324,  274,  274,  257,  276,  283,  211,
  212,  320,  281,  211,  212,  285,  181,  313,  183,  294,
  295,  296,  306,  147,  294,  295,  296,  257,  242,  243,
   57,   58,   62,  181,  248,  183,  260,  292,  293,  294,
  295,  296,  297,  298,  209,  300,   59,   60,  213,  214,
  335,  337,  217,  261,  257,  309,  306,  257,  217,  306,
  184,  209,  336,  322,  321,  213,  214,   62,   62,  217,
  194,  306,  318,  211,  212,  257,  325,  242,  243,  306,
   62,  260,   62,  248,  260,  259,   62,   62,  306,  259,
  273,  260,  259,  302,  242,  243,  287,  260,   62,  257,
  248,  259,  275,  304,   62,  353,  301,  303,  305,  299,
  309,  273,  306,   73,  275,  303,  305,  116,  299,  287,
  306,  131,  131,   74,  136,  118,   76,   -1,  314,   -1,
  314,   -1,   -1,   -1,  306,   -1,  294,  295,   -1,   -1,
  306,  327,  328,  329,  328,  329,  306,  325,   -1,   -1,
  314,  323,  323,   -1,   -1,   -1,   -1,  323,   -1,  316,
  352,  353,   -1,  323,  328,  329,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,  257,   -1,  259,   -1,
  352,  353,  354,  355,  356,  357,  352,  353,  354,  355,
  356,  357,  352,  353,  354,  355,  356,  357,   -1,   -1,
  354,  355,  356,  357,  354,  355,  356,  357,  352,  353,
  352,  353,  352,  294,  295,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  310,
  311,  269,  270,   -1,  272,   -1,  274,   -1,  276,   -1,
  278,   -1,  280,   -1,  282,   -1,  284,   -1,  286,   -1,
   -1,   -1,   -1,   -1,  292,  293,  294,  295,  296,  297,
  298,   -1,  300,
};
}
final static short YYFINAL=2;
final static short YYMAXTOKEN=364;
final static String yyname[] = {
"end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,"'!'",null,null,null,null,null,null,"'('","')'","'*'","'+'",null,
"'-'",null,"'/'",null,null,null,null,null,null,null,null,null,null,null,null,
"'<'",null,"'>'",null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,"IDENTIFIER","NAME","NUMBER","STRING",
"UNFORMATTED_STRING","T_NUDROID","CT_NUDROID","T_NAVIGATION","CT_NAVIGATION",
"T_STYLE","CT_STYLE","T_PAGE","CT_PAGE","T_TEXT","CT_TEXT","T_INPUT","CT_INPUT",
"T_LINK","CT_LINK","T_IMAGE","CT_IMAGE","T_LIST","CT_LIST","T_TABLE","CT_TABLE",
"T_AUDIO","CT_AUDIO","T_VIDEO","CT_VIDEO","T_BUTTON","CT_BUTTON","T_FUNCTION",
"CT_FUNCTION","T_VAR","CT_VAR","T_GOTO","T_SETVAR","T_GETVAR","T_GETINPUT",
"T_GETTEXT","T_SETTEXT","T_LOOP","CT_LOOP","T_TEST","CT_TEST","T_TRUE",
"CT_TRUE","T_FALSE","CT_FALSE","CT_SELF_CLOSING","CT_SETTEXT","T_MENU",
"CT_MENU","B_TRUE","B_FALSE","P_NAME","P_PAGEID","P_URL","P_EMAIL",
"P_BULLET_STYLE","P_TYPE","P_COLS","P_FUNCTIONID","P_VALUE","P_CONDITION",
"P_START","P_END","P_ID","P_LABEL","P_STYLEID","P_POSITION","P_HEIGHT",
"P_WIDTH","P_LOCATION","P_SIZE","P_COLOR","P_FONT","P_LORIENTATION","P_VARID",
"P_TEXTID","P_INPUTID","P_TEXT","FONT_SERIF","FONT_SANS","FONT_MONO",
"BULLET_NUMBERS","BULLET_ATOZ_UPPER","BULLET_ATOZ_LOWER","BULLET_CIRCLES",
"BULLET_SQUARES","BULLET_DISCS","LIST_VERTICAL","LIST_HORIZONTAL","TYPE_NUMBER",
"TYPE_STRING","LOGIC_OR","LOGIC_AND","RELOP_EQ","RELOP_NEQ","RELOP_GEQ",
"RELOP_LEQ","POSITION_TOP","POSITION_BOTTOM","POSITION_LEFT","POSITION_RIGHT",
"POSITION_CENTER","ORIENTATION_VERTICAL","ORIENTATION_HORIZONTAL",
};
final static String yyrule[] = {
"$accept : app",
"app : T_NUDROID app_name '>' navigation body CT_NUDROID",
"body :",
"body : body upper_level_tag",
"upper_level_tag : page",
"upper_level_tag : variable",
"app_name : P_NAME IDENTIFIER",
"navigation :",
"navigation : T_NAVIGATION '>' tabs CT_NAVIGATION",
"tabs :",
"tabs : tabs tab",
"tab : menu",
"menu : T_MENU id page_id '>' unformatted_string CT_MENU",
"page : T_PAGE id page_params '>' page_body CT_PAGE",
"page_body :",
"page_body : page_body body_element",
"body_element : text",
"body_element : input",
"body_element : image",
"body_element : list",
"body_element : table",
"body_element : button",
"body_element : action",
"body_element : audio",
"body_element : video",
"body_element : link",
"page_params :",
"page_params : page_params page_param",
"page_param : label",
"text : T_TEXT id '>' formatted_string CT_TEXT",
"input : T_INPUT id '>' unformatted_string CT_INPUT",
"link : T_LINK id ref '>' unformatted_string CT_LINK",
"ref : url",
"ref : email",
"page_id : P_PAGEID IDENTIFIER",
"url : P_URL STRING",
"email : P_EMAIL STRING",
"image : T_IMAGE id image_params '>' formatted_string CT_IMAGE",
"image : T_IMAGE id image_params CT_SELF_CLOSING",
"image_params :",
"image_params : image_params image_param",
"image_param : height",
"image_param : width",
"image_param : url",
"image_param : position",
"list : T_LIST id list_params '>' list_items CT_LIST",
"list_params :",
"list_params : list_params list_param",
"list_param : bullet",
"list_items :",
"list_items : list_items list_item",
"list_item : text",
"list_item : image",
"list_item : link",
"bullet : P_BULLET_STYLE STRING",
"table : T_TABLE id cols '>' table_items CT_TABLE",
"cols : P_COLS NUMBER",
"table_items :",
"table_items : table_items table_item",
"table_item : text",
"table_item : link",
"table_item : image",
"audio : T_AUDIO id audio_params '>' formatted_string CT_AUDIO",
"audio_params :",
"audio_params : audio_params audio_param",
"audio_param : size",
"audio_param : url",
"video : T_VIDEO id video_params '>' formatted_string CT_VIDEO",
"video_params :",
"video_params : video_params video_param",
"video_param : size",
"video_param : url",
"button : T_BUTTON id label '>' optional_code CT_BUTTON",
"variable : T_VAR id value CT_SELF_CLOSING",
"value : P_VALUE expression",
"code : action",
"code : code action",
"optional_code :",
"optional_code : code",
"action : goto",
"action : setvar",
"action : getvar",
"action : getinput",
"action : gettext",
"action : settext",
"action : test",
"action : loop",
"goto : T_GOTO page_id CT_SELF_CLOSING",
"setvar : T_SETVAR var_id value CT_SELF_CLOSING",
"getvar : T_GETVAR var_id CT_SELF_CLOSING",
"getinput : T_GETINPUT input_id CT_SELF_CLOSING",
"gettext : T_GETTEXT text_id CT_SELF_CLOSING",
"settext : T_SETTEXT text_id '>' formatted_string CT_SETTEXT",
"expression : expression '+' term",
"expression : expression '-' term",
"expression : term",
"term : term '*' factor",
"term : term '/' factor",
"term : factor",
"factor : '(' expression ')'",
"factor : num",
"num : NUMBER",
"num : getvar",
"num : getinput",
"num : IDENTIFIER",
"condition : condition LOGIC_OR condition",
"condition : condition LOGIC_AND condition",
"condition : '!' condition",
"condition : '(' condition ')'",
"condition : expression relop expression",
"condition : B_TRUE",
"condition : B_FALSE",
"relop : '<'",
"relop : '>'",
"relop : RELOP_EQ",
"relop : RELOP_GEQ",
"relop : RELOP_LEQ",
"relop : RELOP_NEQ",
"test : T_TEST P_CONDITION condition '>' true_code false_code CT_TEST",
"true_code : T_TRUE '>' optional_code CT_TRUE",
"false_code : T_FALSE '>' optional_code CT_FALSE",
"loop : T_LOOP P_START expression P_END expression '>' optional_code CT_LOOP",
"id : P_ID IDENTIFIER",
"var_id : P_VARID IDENTIFIER",
"text_id : P_TEXTID IDENTIFIER",
"input_id : P_INPUTID IDENTIFIER",
"label : P_LABEL STRING",
"position : P_POSITION STRING",
"size : width",
"size : height",
"height : P_HEIGHT NUMBER",
"width : P_WIDTH NUMBER",
"formatted_string :",
"formatted_string : formatted_string UNFORMATTED_STRING",
"formatted_string : formatted_string link",
"formatted_string : formatted_string getvar",
"formatted_string : formatted_string getinput",
"formatted_string : formatted_string gettext",
"unformatted_string :",
"unformatted_string : UNFORMATTED_STRING",
};

//#line 1316 "nudroid.y"

private Yylex lexer;
private int layoutParams;
private int numMenuItems;
private static String appName;	
private String variableDeclarations;
private String navigationTemp;
private ArrayList<String> listUrl;
private ArrayList<String> listIDs;
private ArrayList<String>listTitle;
private ArrayList<String> pageIDs;
private ArrayList<String> pageTitles;

public static void main(String args[])
{    
	
	Parser yyparser;
	
	SymbolTable.initialize();
	
	try {
		yyparser = new Parser(new FileReader(args[0]));
		yyparser.yyparse();  
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} 
}

public static StringBuilder readFile(String srcFile)
{
	StringBuilder nudroidSoucre = new StringBuilder();
	
	try
	{
		// File open
		File dirs = new File(srcFile);
		String path = dirs.getAbsolutePath();
		File realFile = new File(path);			
		FileReader fr=new FileReader(realFile);
		BufferedReader br = new BufferedReader(fr);	
	  	  
	  String str="";
  	
  	while ((str=br.readLine())!=null)
  	{
  		nudroidSoucre.append(str);
  	}
	  			
		return nudroidSoucre;
	}
	catch (Exception e)
	{
		e.getMessage();
		System.out.println("File open error: " + e);
		
		return null;
	}
}
  /* interface to the lexer */
  private int yylex () {
    int yyl_return = -1;
    try {
      yyl_return = lexer.yylex();
    }
    catch (IOException e) {
      System.err.println("IO error :"+e);
    }
    
    return yyl_return;
  }

void yyerror(String s)
{
	System.err.println("Error: "+s);
}

  /* lexer is created in the constructor */
  public Parser(Reader r) {
    lexer = new Yylex(r, this);
    layoutParams=1; //Increments to ensure unique page member names.
    numMenuItems = 0;
    navigationTemp = "";
    pageIDs = new ArrayList<String>();
    pageTitles = new ArrayList<String>();
    listIDs = new ArrayList<String>();
    listUrl = new ArrayList<String>();
	listTitle = new ArrayList<String>();
    //symbolTable = new HashMap<String, Type>();
    variableDeclarations = "";
  }
  
  public String addName(String name, String functions)
  {
  	return addName(name, functions, 0);
  }
  
  /* Add id name to start of parameters
  	 e.g. addName("x", ".f(y)\n.g(z)\nw.f(y)", 0) -->
  	      "x.f(y)
  	      x.g(z)
  	      w.f(y)" 
  */
public String addName(String name, String functions, int tabs)
  {
  	//System.out.println("name = " name + " functions = " + functions);
  	String output = "";
  	boolean foundDot = false;
  	boolean foundSlash = false;
  	
  	for(int i = 0; i < functions.length(); i++)
  	{
  		char nextChar = functions.charAt(i);
  		//System.out.print(nextChar + "");
  		if(nextChar == '.' && !foundDot)
  		{
  		//	System.out.print(" Found dot!\n");
  			output += name + ".";
  			foundDot = true;
  		}
  		else if(nextChar == '\\')
  		{
  		//	System.out.print(" Found slash!\n");
  			foundSlash = true;
  			output += '\\';
  		}
  		else if (nextChar == '\n')
  		{
  			//System.out.print(" Newline, reset.\n");
  			foundDot = false;
  			//foundSlash = false;
  			output += nextChar;
  			for(int j = 0; i < tabs; j++)
  				output += "\t";
  		}
  		else if ((nextChar == '\t' || nextChar == '\r'))
  		{
  		    //System.out.print(" Whitespace, keep going.\n");
  			//foundSlash = false;
  			output += nextChar;
  		}
  		else if (nextChar == ' ')
  		{
  			//System.out.print(" Found space.\n");
  			output += nextChar;
  		}
  		else
  		{
  			//System.out.print(" Non-whitespace, non-dot. No dotting here.\n");
  			foundDot = true; //Make sure not to put name before other invocations
  			output += nextChar;
  		}
  			
  	}
  	return output;
  }
  
//#line 768 "Parser.java"
//###############################################################
// method: yylexdebug : check lexer state
//###############################################################
void yylexdebug(int state,int ch)
{
String s=null;
  if (ch < 0) ch=0;
  if (ch <= YYMAXTOKEN) //check index bounds
     s = yyname[ch];    //now get it
  if (s==null)
    s = "illegal-symbol";
  debug("state "+state+", reading "+ch+" ("+s+")");
}





//The following are now global, to aid in error reporting
int yyn;       //next next thing to do
int yym;       //
int yystate;   //current parsing state from state table
String yys;    //current token string


//###############################################################
// method: yyparse : parse input and execute indicated items
//###############################################################
int yyparse()
{
boolean doaction;
  init_stacks();
  yynerrs = 0;
  yyerrflag = 0;
  yychar = -1;          //impossible char forces a read
  yystate=0;            //initial state
  state_push(yystate);  //save it
  val_push(yylval);     //save empty value
  while (true) //until parsing is done, either correctly, or w/error
    {
    doaction=true;
    if (yydebug) debug("loop"); 
    //#### NEXT ACTION (from reduction table)
    for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate])
      {
      if (yydebug) debug("yyn:"+yyn+"  state:"+yystate+"  yychar:"+yychar);
      if (yychar < 0)      //we want a char?
        {
        yychar = yylex();  //get next token
        if (yydebug) debug(" next yychar:"+yychar);
        //#### ERROR CHECK ####
        if (yychar < 0)    //it it didn't work/error
          {
          yychar = 0;      //change it to default string (no -1!)
          if (yydebug)
            yylexdebug(yystate,yychar);
          }
        }//yychar<0
      yyn = yysindex[yystate];  //get amount to shift by (shift index)
      if ((yyn != 0) && (yyn += yychar) >= 0 &&
          yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
        {
        if (yydebug)
          debug("state "+yystate+", shifting to state "+yytable[yyn]);
        //#### NEXT STATE ####
        yystate = yytable[yyn];//we are in a new state
        state_push(yystate);   //save it
        val_push(yylval);      //push our lval as the input for next rule
        yychar = -1;           //since we have 'eaten' a token, say we need another
        if (yyerrflag > 0)     //have we recovered an error?
           --yyerrflag;        //give ourselves credit
        doaction=false;        //but don't process yet
        break;   //quit the yyn=0 loop
        }

    yyn = yyrindex[yystate];  //reduce
    if ((yyn !=0 ) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
      {   //we reduced!
      if (yydebug) debug("reduce");
      yyn = yytable[yyn];
      doaction=true; //get ready to execute
      break;         //drop down to actions
      }
    else //ERROR RECOVERY
      {
      if (yyerrflag==0)
        {
        yyerror("syntax error");
        yynerrs++;
        }
      if (yyerrflag < 3) //low error count?
        {
        yyerrflag = 3;
        while (true)   //do until break
          {
          if (stateptr<0)   //check for under & overflow here
            {
            yyerror("stack underflow. aborting...");  //note lower case 's'
            return 1;
            }
          yyn = yysindex[state_peek(0)];
          if ((yyn != 0) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
            {
            if (yydebug)
              debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" ");
            yystate = yytable[yyn];
            state_push(yystate);
            val_push(yylval);
            doaction=false;
            break;
            }
          else
            {
            if (yydebug)
              debug("error recovery discarding state "+state_peek(0)+" ");
            if (stateptr<0)   //check for under & overflow here
              {
              yyerror("Stack underflow. aborting...");  //capital 'S'
              return 1;
              }
            state_pop();
            val_pop();
            }
          }
        }
      else            //discard this token
        {
        if (yychar == 0)
          return 1; //yyabort
        if (yydebug)
          {
          yys = null;
          if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
          if (yys == null) yys = "illegal-symbol";
          debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")");
          }
        yychar = -1;  //read another
        }
      }//end error recovery
    }//yyn=0 loop
    if (!doaction)   //any reason not to proceed?
      continue;      //skip action
    yym = yylen[yyn];          //get count of terminals on rhs
    if (yydebug)
      debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")");
    if (yym>0)                 //if count of rhs not 'nil'
      yyval = val_peek(yym-1); //get current semantic value
    yyval = dup_yyval(yyval); //duplicate yyval if ParserVal is used as semantic value
    switch(yyn)
      {
//########## USER-SUPPLIED ACTIONS ##########
case 1:
//#line 151 "nudroid.y"
{

	/* To initialize variables*/
	try
	{
		String initFile = "package pkg.nudroid;\n" +

		"public class Init\n"+
		"{\n" + 
		"\tstatic void init()\n" +
		"\t{\n" +
		variableDeclarations +
		"\t}\n" +
		"}";
		
		String path = System.getProperty("user.dir")  + "/src/pkg/nudroid/" + "Init" + ".java";
		FileWriter fw = new FileWriter(path);
		fw.write(initFile);
		fw.close();
		System.out.println("Successed");
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}

	/* To make folder*/
	try
	{			
		/*
		// make directory hierarchy
		File f1, f2, f3, f4, f5, f6, f7, f8;
		
	    f1 = new File($2.sval + "/gen");
	    f2 = new File($2.sval + "/assets");
	    f3 = new File($2.sval + "/src/pkg/nudroid");
	    if (!f1.mkdirs() || !f2.mkdirs() || !f3.mkdirs())
	      System.err.println("fail to create directory");
		
	    // make sub-directory 
	    f4 = new File($2.sval + "/res/drawable-hdpi");
	    f5 = new File($2.sval + "/res/drawable-ldpi");
	    f6 = new File($2.sval + "/res/drawable-mdpi");
	    f7 = new File($2.sval + "/res/layout");
	    f8 = new File($2.sval + "/res/values");
	    if (!f4.mkdirs() || !f5.mkdirs() || !f6.mkdirs() || !f7.mkdirs() || !f8.mkdirs())
	      System.err.println("fail to create directory");	 
	    */
	      
    	BufferedWriter out1, out2, out3;
    	String s1, s2, s3;
    	
    	/* first file*/
		  out1 = new BufferedWriter(new FileWriter(System.getProperty("user.dir") + "/src/pkg/nudroid/AndroidManifest.xml"));
		  
		  s1 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";		
		  out1.write(s1); out1.newLine();
		  s1 = "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"";
		  out1.write(s1); out1.newLine();	
		  s1 = "\tpackage=\"pkg.nudroid\"";
		  out1.write(s1); out1.newLine();	
		  s1 = "\tandroid:versionCode=\"1\"";
		  out1.write(s1); out1.newLine();
		  s1 = "\tandroid:versionName=\"1.0\">";
		  out1.write(s1); out1.newLine();
		  s1 = "\t\t\t\t<uses-permission android:name=\"android.permission.INTERNET\" />";
		  out1.write(s1); out1.newLine();	
		  s1 = "\t<application android:icon=\"@drawable/icon\" android:label=\"" + val_peek(4).sval + "\">";
		  out1.write(s1); out1.newLine();
		  
		  s1 = "\t\t<activity android:name=\"." + pageIDs.get(0) + "\"";		
		  out1.write(s1); out1.newLine();
		  s1 = "\t\t\tandroid:label=\"" + pageIDs.get(0) + "\">";
		  out1.write(s1); out1.newLine();		  
		  s1 = "\t\t\t\t<intent-filter>";
		  out1.write(s1); out1.newLine();
		  s1 = "\t\t\t\t\t<action android:name=\"android.intent.action.MAIN\" />";
		  out1.write(s1); out1.newLine();
		  s1 = "\t\t\t\t\t<category android:name=\"android.intent.category.LAUNCHER\" />";
		  out1.write(s1); out1.newLine();
		  s1 = "\t\t\t\t</intent-filter>";
		  out1.write(s1); out1.newLine();
		  s1 = "\t\t</activity>	";
		  out1.write(s1); out1.newLine();
		  
		  /* It should make all page activity*/
		 for(int i = 1; i < pageIDs.size(); i ++)
		{
			s1 = "\t\t<activity android:name=\"." + pageIDs.get(i) + "\"";		
			out1.write(s1); out1.newLine();
			s1 = "\t\t\tandroid:label=\"" + pageIDs.get(i) + "\">";
		  	out1.write(s1); out1.newLine();
		  	s1 = "\t\t</activity>	";
		  	out1.write(s1); out1.newLine();
		  
		};
		  		  	  
		  s1 = "\t</application>";
		  out1.write(s1); out1.newLine();
		  s1 = "\t<uses-sdk android:minSdkVersion=\"7\" />";
		  out1.write(s1); out1.newLine();
		  s1 = "</manifest> ";
		  out1.write(s1); out1.newLine();
		  out1.close();      
		
		  /* second file*/
		
		  out2 = new BufferedWriter(new FileWriter(System.getProperty("user.dir") + "/src/pkg/nudroid/default.properties"));

		  s2 = "# Indicates whether an apk should be generated for each density.";
		  out2.write(s2); out2.newLine();
		  s2 = "split.density=false";		
		  out2.write(s2); out2.newLine();
		  s2 = "# Project target.";
		  out2.write(s2); out2.newLine();	
		  s2 = "target=android-7";
		  out2.write(s2); out2.newLine();	
		  out2.close();
		  
		  /* third file*/
		  out3 = new BufferedWriter(new FileWriter(System.getProperty("user.dir") + "/src/pkg/nudroid/row.xml"));
		  s3 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
		  out3.write(s3); out3.newLine();
		  s3 = "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"";		
		  out3.write(s3); out3.newLine();
		  s3 = "android:layout_width=\"fill_parent\" android:layout_height=\"wrap_content\"";
		  out3.write(s3); out3.newLine();	
		  s3 = "android:orientation=\"horizontal\">";
		  out3.write(s3); out3.newLine();	
		  s3 = "<TableRow android:id=\"@+id/TableRow\" android:layout_width=\"wrap_content\"";
		  out3.write(s3); out3.newLine();
		  s3 = "android:layout_height=\"wrap_content\">";
		  out3.write(s3); out3.newLine();
		  s3 = "<ImageView ";
		  out3.write(s3); out3.newLine();
		  s3 = "android:id=\"@+id/bulletpoint\"";
		  out3.write(s3); out3.newLine();
		  s3 = "android:paddingLeft=\"0px\" android:paddingRight=\"0px\"";
		  out3.write(s3); out3.newLine();
		  s3 = "android:paddingTop=\"0px\" android:layout_height=\"wrap_content\"/>";
		  out3.write(s3); out3.newLine();
		  s3 = "<TextView ";
		  out3.write(s3); out3.newLine();
		  s3 = "android:id=\"@+id/text\"";
		  out3.write(s3); out3.newLine();
		  s3 = "android:text=\"\"";
		  out3.write(s3); out3.newLine();
		  s3 = "android:layout_width=\"wrap_content\"";
		  out3.write(s3); out3.newLine();
		  s3 = "android:layout_height=\"24sp\"";
		  out3.write(s3); out3.newLine();
		  s3 = "android:textSize=\"16sp\" />";
		  out3.write(s3); out3.newLine();
		  s3 = "</TableRow>";
		  out3.write(s3); out3.newLine();
		  s3 = "</LinearLayout>";
		  out3.write(s3); out3.newLine();
		  out3.close();
		  		  
	}
	catch (Exception e)
	{
		System.out.println("Err: Make folder - " + e);
	}
}
break;
case 2:
//#line 319 "nudroid.y"
{yyval.sval = "";}
break;
case 3:
//#line 320 "nudroid.y"
{yyval.sval = val_peek(1).sval + val_peek(0).sval;}
break;
case 4:
//#line 323 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 5:
//#line 324 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 6:
//#line 327 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 7:
//#line 331 "nudroid.y"
{;}
break;
case 8:
//#line 333 "nudroid.y"
{ 	
	yyval.sval = 
	"\n\t//Navigation\n" +
	"\t@Override\n" +
	"\tpublic boolean onCreateOptionsMenu(Menu menu)\n" +
	"\t{\n" +
	"\t\tsuper.onCreateOptionsMenu(menu);\n";
			
	for(int i = 0; i < pageTitles.size(); i ++)
	{		
		yyval.sval = yyval.sval + "\t\tmenu.add(0," + i + "," + i +"," + pageTitles.get(i) + ");\n";
	};
	
	yyval.sval = yyval.sval +
	    "\t\treturn true;\n" +
	"\t}\n" +
	
	"\n\t@Override\n" +
	"\tpublic boolean onOptionsItemSelected(MenuItem item)\n" +
	"\t{\n" +
	"\t\tsuper.onOptionsItemSelected(item);	\n" +
		"\t\tswitch (item.getItemId())\n" +
		"\t\t{\n";
		
	for(int i = 0; i < pageTitles.size(); i ++)
	{
		yyval.sval = yyval.sval +  
		"\t\tcase " + i + ":\n" +
		"\t\t startActivity(new Intent(this," + pageIDs.get(i) + ".class));\n" +
		"\t\treturn true;\n";
	};	
	
	yyval.sval = yyval.sval +	
	"\t\t}\n" +
	"\t\treturn super.onOptionsItemSelected(item);\n" +
	"\t}\n";
		
	navigationTemp = yyval.sval;
}
break;
case 9:
//#line 374 "nudroid.y"
{yyval.sval = "";}
break;
case 11:
//#line 378 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 12:
//#line 384 "nudroid.y"
{
	pageIDs.add(val_peek(3).sval);
	pageTitles.add(val_peek(1).sval);
}
break;
case 13:
//#line 393 "nudroid.y"
{
	if(val_peek(4).sval != "" && !pageIDs.contains(val_peek(4).sval))
	{
		System.out.println("Page: " + val_peek(4).sval);
		pageIDs.add(val_peek(4).sval);
		if(val_peek(3).sval != "")
			pageTitles.add(val_peek(3).sval); /*for now, since label is only param*/
		else
			pageTitles.add(val_peek(4).sval);
	}
	
	yyval.sval = 
	
	"package pkg.nudroid;\n\n" +
	"import android.view.LayoutInflater;\n" + 
	"import android.net.Uri;\n" +
	"import android.widget.AdapterView.OnItemClickListener;\n" +
	"import android.app.Activity;\n" +
	"import java.util.ArrayList;\n" +
	"import android.view.Menu;\n" +
	"import android.view.MenuItem;\n" +	
	"import android.view.View;\n" +	
	"import android.view.ViewGroup;\n" + 
	"import android.os.Bundle;\n" +
	"import android.widget.*;\n" +
	"import android.content.Intent;\n" +
	"import android.view.ViewGroup.LayoutParams;\n" +
	"import android.graphics.*;\n" +
	"import java.net.*;\n" +
	"import java.io.InputStream;\n" +
	"import android.text.util.Linkify;\n" +
	"import android.media.MediaPlayer;\n" +
	"import java.io.BufferedInputStream;\n\n" +
			
	"public class " + val_peek(4).sval + " extends Activity\n" + 
	"{\n" +
		"\t// Default layout\n" +
	    "\tRelativeLayout nudroidLayout;\n" +
	    "\tIntent intent;\n" +
	    "\tint autoID = 1;\n" +
	    "\tprivate ArrayList<String> listTitleData = new ArrayList<String>();\n" +
		"\tArrayList<ListData> items = new ArrayList<ListData>();\n\n" +
	
		"\tpublic class ListData\n" + 
		"\t{\n" +
			"\t\tpublic String text = \"\";\n" + 
			"\t\tpublic int bulletpoint;\n" +
		"\t}\n\n" +
	
		"\t@Override\n"+
		"\tpublic void onCreate(Bundle savedInstanceState)\n"+ 
		"\t{\n"+
		"\t\tsuper.onCreate(savedInstanceState);\n"+
        "\n\t\t// To create default layout\n"+
        "\t\tnudroidLayout = new RelativeLayout(this);\n"+
        "\t\tfinal Activity thisPage = this;\n" +
                        
        "\n\t\t// To create page text\n" +
        "\t\tTextView " + val_peek(4).sval + "= new TextView(this);\n" +
        "\t\t" + val_peek(4).sval + ".setText(\"" + val_peek(3).sval + "\");\n" +
        "\t\t" + val_peek(4).sval + ".setId(autoID++);\n" +
                
		"\n\t\t// To define layout param\n" +
		"\t\tRelativeLayout.LayoutParams lpPage = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n"+
        "\t\tlpPage.addRule(RelativeLayout.CENTER_HORIZONTAL);\n" +
        "\t\t" + val_peek(4).sval + ".setLayoutParams(lpPage);\n\n" +
        
        "\t\tnudroidLayout.addView(" + val_peek(4).sval + ");\n" +
        
        "\t\t// To create dummy text\n" +
		"\t\tTextView dummy = new TextView(this);\n" +
		"\t\tdummy.setText(\" \");\n" +
		"\t\tdummy.setId(autoID++);\n" +
		
		"\t\t// To define layout param\n" +
		"\t\tRelativeLayout.LayoutParams lpPagedummy = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n" +
		"\t\tlpPagedummy.addRule(RelativeLayout.BELOW, autoID-2);\n" +
		"\t\tdummy.setLayoutParams(lpPagedummy);\n" +
		"\t\tnudroidLayout.addView(dummy);\n" +
        
        val_peek(1).sval + 
        
        "\n\t\t// To show views\n"+
        "\t\tsetContentView(nudroidLayout);\n"+
		"\t}\n" +
				
		navigationTemp +
		
		"\tclass IconicAdapter extends ArrayAdapter<ListData>\n" + 
		"\t{\n" + 
		"\t\tprivate LayoutInflater mInflater;\n" + 
		"\t\tActivity context;\n\n" + 
		"\t\tIconicAdapter(Activity context)\n" + 
		"\t\t{\n" + 
			"\t\t\tsuper(context, R.layout.row, items);\n" + 
			"\t\t\tmInflater = LayoutInflater.from(context);\n" + 
			"\t\t\tthis.context = context;\n" + 
		"\t\t}\n\n" + 

		"\t\tclass ViewHolder\n\n" + 
		"\t\t{\n" + 
			"\t\t\tTextView text;\n" + 
			"\t\t\tImageView icon;\n" + 
		"\t\t}\n\n" + 

		"\t\tpublic View getView(int position, View convertView, ViewGroup parent)\n" + 
		"\t\t{\n" + 
			"\t\t\tViewHolder holder;\n" + 
			"\t\t\tif (convertView == null)\n" + 
			"\t\t\t{\n" + 
				"\t\t\t\tconvertView = mInflater.inflate(R.layout.row, null);\n" + 
				"\t\t\t\tholder = new ViewHolder();\n" + 
				"\t\t\t\tholder.text = (TextView) convertView.findViewById(R.id.text);\n" + 
				"\t\t\t\tholder.icon = (ImageView) convertView.findViewById(R.id.bulletpoint);\n" + 
				"\t\t\t\tconvertView.setTag(holder);\n" + 
			"\t\t\t}\n" + 
			"\t\t\telse\n" + 
			"\t\t\t{\n" + 
				"\t\t\t\tholder = (ViewHolder) convertView.getTag();\n" + 
			"\t\t\t}\n" + 
			"\t\t\tholder.text.setText(items.get(position).text);\n" + 
			"\t\t\tholder.icon.setImageResource(items.get(position).bulletpoint);\n" +
			"\t\t\tLinkify.addLinks(holder.text, Linkify.WEB_URLS );\n" +			 
			"\t\t\treturn convertView;\n" +
		"\t\t}\n" + 
	"\t}\n" + 
      
      "}\n";
      
        /*
        	Moon, page_body isn't plaintext. It's object tags.
        	Don't think it's a good idea to use same variable names for
        	each page, either. --Stu 
        */
        
        /* 
        	Note: Make sure that all helper variable names are not allowed
                  for identifiers in the lexer.
        */
	
	/* To save file*/
	try
	{
		/*TODO - Giving compilation errors.*/
		File dirs = new File(val_peek(4).sval);
		
		String path = System.getProperty("user.dir") + "/src/pkg/nudroid/" + val_peek(4).sval + ".java";
		FileWriter fw = new FileWriter(path);
		fw.write(yyval.sval);
		fw.close();
		System.out.println("Successed");
	}
	catch (IOException e)
	{
		e.getMessage();
		System.out.println("File open error: " + e);
	}
        layoutParams++; /*Increments counter to ensure unique variable names for next run.*/
}
break;
case 14:
//#line 555 "nudroid.y"
{yyval.sval = "";}
break;
case 15:
//#line 556 "nudroid.y"
{yyval.sval=val_peek(1).sval+val_peek(0).sval;}
break;
case 16:
//#line 559 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 17:
//#line 560 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 18:
//#line 561 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 19:
//#line 562 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 20:
//#line 563 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 21:
//#line 564 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 22:
//#line 565 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 23:
//#line 567 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 24:
//#line 568 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 25:
//#line 570 "nudroid.y"
{
   	yyval.sval = val_peek(0).sval;
   	listIDs.remove(listIDs.size()-1);
   	listTitle.remove(listTitle.size()-1);
   	listUrl.remove(listUrl.size()-1);
   }
break;
case 26:
//#line 578 "nudroid.y"
{yyval.sval = "";}
break;
case 27:
//#line 579 "nudroid.y"
{ yyval.sval = val_peek(1).sval + val_peek(0).sval;}
break;
case 28:
//#line 582 "nudroid.y"
{ yyval.sval = val_peek(0).sval; }
break;
case 29:
//#line 588 "nudroid.y"
{
	yyval.sval = "\n\t\t// To create text\n" +
	"\t\tfinal TextView " + val_peek(3).sval + " = new TextView(this);\n" +
	"\t\t" + val_peek(3).sval + ".setText(" + val_peek(1).sval + ");\n" +
	"\t\t" + val_peek(3).sval + ".setId(autoID++);\n" +
	
	"\n\t\t// To define layout param\n" +
	"\t\tRelativeLayout.LayoutParams lpText" + val_peek(3).sval + " = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n"+
    "\t\tlpText" + val_peek(3).sval + ".addRule(RelativeLayout.BELOW, autoID-2);\n" +
    "\t\t" + val_peek(3).sval + ".setLayoutParams(lpText" + val_peek(3).sval + ");\n\n" +
    "\t\tnudroidLayout.addView(" + val_peek(3).sval + ");\n"
	;
}
break;
case 30:
//#line 606 "nudroid.y"
{
	SymbolTable.initializeInput(val_peek(3).sval);
	
	yyval.sval = 
	"\n\t\t//Input Start;\n" +
	
	"\t\tRelativeLayout.LayoutParams lp" + val_peek(3).sval + " = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n" +
	"\t\tlp" + val_peek(3).sval + ".addRule(RelativeLayout.BELOW, autoID-2);\n" +
	
	"\t\tfinal EditText " + val_peek(3).sval + " = new EditText(this);\n" +
	"\t\t" + val_peek(3).sval + ".setText(" + val_peek(1).sval + ");\n" +
	"\t\t" + val_peek(3).sval + ".setId(autoID++);\n" +
	"\t\t" + val_peek(3).sval + ".setLayoutParams(lp" + val_peek(3).sval + ");\n" +
	"\t\tnudroidLayout.addView(" + val_peek(3).sval + ");\n" +
	"\t\t//Input End;\n"
;}
break;
case 31:
//#line 627 "nudroid.y"
{
	yyval.sval = "\n\t\t// To create link\n" +
	"\t\tTextView link_" + val_peek(4).sval + " = new TextView(this);\n" +
	"\t\tlink_" + val_peek(4).sval + ".setText(\"" + val_peek(3).sval + "\");\n" +
	"\t\tlink_" + val_peek(4).sval + ".setId(autoID++);\n" +
	"\t\tLinkify.addLinks(link_" + val_peek(4).sval + ", Linkify.WEB_URLS );\n" +
		
	"\n\t\t// To define layout param\n" +
	"\t\tRelativeLayout.LayoutParams lpLink" + val_peek(4).sval + " = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n"+
    "\t\tlpLink" + val_peek(4).sval + ".addRule(RelativeLayout.BELOW, autoID-2);\n" +
    "\t\tlink_" + val_peek(4).sval + ".setLayoutParams(lpLink" + val_peek(4).sval + ");\n\n" +
    	
	"\t\tnudroidLayout.addView(link_" + val_peek(4).sval + ");\n\n" +
	"\t\t// Need to show link description\n"
	;
	
	listIDs.add(val_peek(4).sval);
	listUrl.add(val_peek(3).sval);
	listTitle.add(val_peek(1).sval);
}
break;
case 32:
//#line 650 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 33:
//#line 652 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 34:
//#line 655 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 35:
//#line 659 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 36:
//#line 662 "nudroid.y"
{yyval.sval = val_peek(1).sval + val_peek(0).sval;}
break;
case 37:
//#line 667 "nudroid.y"
{
	yyval.sval = "\n\t\t// To create image\n" +
		"\t\tImageView iv" + val_peek(4).sval + " = new ImageView(this);\n" +
		"\t\tURL iu" + val_peek(4).sval + " = null;\n" +
		"\t\tURLConnection co" + val_peek(4).sval + " = null;\n" +
		"\t\tInputStream is" + val_peek(4).sval + " = null;\n\n" +
		"\t\ttry {\n" +
		"\t\t\tiu" + val_peek(4).sval + " = new URL(\"" + val_peek(3).sval + "\");\n" +
		"\t\t\tco" + val_peek(4).sval + " = iu" + val_peek(4).sval + ".openConnection();\n" +
		"\t\t\tco" + val_peek(4).sval + ".connect();\n" +
		"\t\t\tis" + val_peek(4).sval + " = co" + val_peek(4).sval + ".getInputStream();\n" +
		"\t\t\tBufferedInputStream bis" + val_peek(4).sval + " = new BufferedInputStream(is" + val_peek(4).sval + ");\n" +
		"\t\t\tBitmap bm" + val_peek(4).sval + " = BitmapFactory.decodeStream(bis" + val_peek(4).sval + ");\n" +
		"\t\t\tbis" + val_peek(4).sval + ".close();\n" +
		"\t\t\tis" + val_peek(4).sval + ".close();\n" +
		"\t\t\tiv" + val_peek(4).sval + ".setImageBitmap(bm" + val_peek(4).sval + ");\n" +
		"\t\t} catch (Exception e) {\n" +
		"\t\t\te.printStackTrace();\n" +
		"\t\t}\n\n" +
		
		"\t\tiv" + val_peek(4).sval + ".setAdjustViewBounds(true);\n" +
		"\t\tiv" + val_peek(4).sval + ".setId(autoID++);\n" +
		/*"\t\tiv" + $2.sval + ".setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));\n" +*/
		"\t\tiv" + val_peek(4).sval + ".setScaleType(ImageView.ScaleType.FIT_XY);\n" +
		
		
		"\n\t\t// To define layout param\n" +
		"\t\tRelativeLayout.LayoutParams lp" + val_peek(4).sval + " = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n"+
    	"\t\tlp" + val_peek(4).sval + ".addRule(RelativeLayout.BELOW, autoID-2);\n" +
    	"\t\tiv" + val_peek(4).sval + ".setLayoutParams(lp" + val_peek(4).sval + ");\n" +
    
    	"\n\t\tnudroidLayout.addView(iv" + val_peek(4).sval + ");\n" +
    
		"\n\t\t// Need to do more to show image description\n" +
		
		
				
		"\t\t// To create text\n" +
		"\t\tTextView tv" + val_peek(4).sval + " = new TextView(this);\n" +
		"\t\ttv" + val_peek(4).sval + ".setText(" + val_peek(1).sval + ");\n" +
		"\t\ttv" + val_peek(4).sval + ".setId(autoID++);\n" +

		"\t\t// To define layout param\n" +
		"\t\tRelativeLayout.LayoutParams lp2" + val_peek(4).sval + " = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n" +
		"\t\tlp2" + val_peek(4).sval + ".addRule(RelativeLayout.BELOW, autoID-2);\n" +
		"\t\ttv" + val_peek(4).sval + ".setLayoutParams(lp2" + val_peek(4).sval + " );\n" +

		"\t\tnudroidLayout.addView(tv" + val_peek(4).sval + ");\n" ;
		
}
break;
case 38:
//#line 718 "nudroid.y"
{
		
/*   	$$.sval = 
	"\t\t//Image2 Start;\n" +
	"\t\t\n" +
	"\t\t\n" +
	"\t\t\n" +
	"\t\t//Image2 End;\n"
	;
*/
   }
break;
case 39:
//#line 732 "nudroid.y"
{yyval.sval = "";}
break;
case 40:
//#line 733 "nudroid.y"
{yyval.sval = val_peek(1).sval + val_peek(0).sval;}
break;
case 45:
//#line 744 "nudroid.y"
{       
		yyval.sval = 
		"\n\t\tListView " + val_peek(4).sval + "= new ListView(this);\n" + 
		"\t\titems.clear();\n";
         
        for(int i = 0; i < listIDs.size(); i ++)
		{
 			yyval.sval = yyval.sval + "\n\t\tListData " + listIDs.get(i) + "= new ListData();\n" +       
        						"\t\t" + listIDs.get(i) + ".text = " + listTitle.get(i) + ";\n" +
    							"\t\titems.add(" + listIDs.get(i) + ");\n" +
    							"\t\tlistTitleData.add(\"" + listUrl.get(i) + "\");\n";
        };       
               
        yyval.sval = yyval.sval +         
        		 
        "\n\t\t" + val_peek(4).sval + ".setAdapter(new IconicAdapter(this));\n" + 
		"\t\t" + val_peek(4).sval + ".setId(autoID++);\n" +
	
		"\n\t\t// To define layout param\n" +
		"\t\tRelativeLayout.LayoutParams lpList" + val_peek(4).sval + " = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n"+
	    "\t\tlpList" + val_peek(4).sval + ".addRule(RelativeLayout.BELOW, autoID-2);\n" +
	    "\t\t" + val_peek(4).sval + ".setLayoutParams(lpList" + val_peek(4).sval + ");\n\n" +
	    		
		"\t\t" + val_peek(4).sval + ".setOnItemClickListener(new OnItemClickListener()\n" +
		"\t\t{\n" +
			"\t\t\t@Override\n" +
			"\t\t\tpublic void onItemClick(AdapterView<?> parent, View v, int position, long id)\n" +
			"\t\t\t{\n" +
			
				"\t\t\t\tIntent web = new Intent(Intent.ACTION_VIEW);\n" +
				"\t\t\t\tUri u = Uri.parse(listTitleData.get(position));\n" +
				"\t\t\t\tweb.setData(u);\n" +
				"\t\t\t\tstartActivity(web);\n" +
			"\t\t\t}\n" +
		"\t\t});\n\n" +
	    
	    
	    "\t\tnudroidLayout.addView(" + val_peek(4).sval + ");\n";
}
break;
case 50:
//#line 796 "nudroid.y"
{
   	yyval.sval = val_peek(1).sval + val_peek(0).sval
   ;
   }
break;
case 51:
//#line 802 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 53:
//#line 804 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 55:
//#line 820 "nudroid.y"
{
	/* get table name*/
	String table_id = val_peek(4).sval;
	/* get list of table parameters*/
	String table_params = val_peek(3).sval;
	/* get list of table items*/
	String table_items = val_peek(1).sval;
	
	/* extract cols*/
	int cols = (int)(val_peek(3).dval);
	
	/* build XML layout contents*/
	LayoutBuilder LB = new LayoutBuilder();
	String table = LB.makeTable(cols);
	table += LB.addToTable("THIS",120);
	table += LB.addToTable("IS",120);
	table += LB.addToTable("A TEST",120);
	table += LB.returnTable();
	
	LB.commitLayout(table, table_id);
	
	yyval.sval = 
	"\t\tTableLayout table_"+table_id+" = (TableLayout) findViewById(R.layout."+table_id+");\n" +
	"\t\tnudroidLayout.addView(table_"+table_id+");\n\n";
	
}
break;
case 56:
//#line 865 "nudroid.y"
{
	yyval.dval = val_peek(0).dval;
}
break;
case 59:
//#line 874 "nudroid.y"
{System.out.println("Text in table");}
break;
case 60:
//#line 875 "nudroid.y"
{System.out.println("Link in table");}
break;
case 61:
//#line 876 "nudroid.y"
{System.out.println("Image in table");}
break;
case 62:
//#line 894 "nudroid.y"
{
	String name = "mp" + val_peek(4).sval;
	yyval.sval = "\t\tMediaPlayer " + name + " = new MediaPlayer();\n" +
	"\t\ttry {\n" +
    addName(name, val_peek(3).sval,3) + 
    "\t\t\t" + name + ".prepare();\n" +
    "\t\t\t" +name + ".start();\n" +
    "\t\t} catch (Exception e) {\n" +
		"\t\t\te.printStackTrace();\n" +
		"\t\t}\n\n" +
				
		"\t\t// To create text\n" +
		"\t\tTextView tv" + val_peek(4).sval + " = new TextView(this);\n" +
		"\t\ttv" + val_peek(4).sval + ".setText(" + val_peek(1).sval + ");\n" +
		"\t\ttv" + val_peek(4).sval + ".setId(autoID++);\n" +

		"\t\t// To define layout param\n" +
		"\t\tRelativeLayout.LayoutParams lp" + val_peek(4).sval + " = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n" +
		"\t\tlp" + val_peek(4).sval + ".addRule(RelativeLayout.BELOW, autoID-2);\n" +
		"\t\ttv" + val_peek(4).sval + ".setLayoutParams(lp" + val_peek(4).sval + " );\n" +

		"\t\tnudroidLayout.addView(tv" + val_peek(4).sval + ");\n" ;
    
    System.out.println("Video code:\n" + yyval.sval);
}
break;
case 63:
//#line 922 "nudroid.y"
{System.out.println("Empty audio param"); yyval.sval = "";}
break;
case 64:
//#line 923 "nudroid.y"
{System.out.println("Recursive video param"); yyval.sval = val_peek(1).sval + val_peek(0).sval;}
break;
case 66:
//#line 927 "nudroid.y"
{System.out.println("URL"); yyval.sval = ".setDataSource(\"" + val_peek(0).sval + "\");\n";}
break;
case 67:
//#line 932 "nudroid.y"
{
	yyval.sval = "\n\t\t// To create video\n" +
	"\t\tString path = \""+ val_peek(3).sval + "\";\n" +
	"\t\tVideoView " + val_peek(4).sval + " = new VideoView(this);\n" +
	"\t\t" + val_peek(4).sval + ".setVideoPath(path);\n" +
	"\t\t" + val_peek(4).sval + ".setId(autoID++);\n" +
	
	"\t\t"  + val_peek(4).sval + ".setMediaController(new MediaController(this));\n" +
	"\t\t" + val_peek(4).sval + ".requestFocus();\n" +
	
	"\n\t\t// To define layout param\n" +
	"\t\tRelativeLayout.LayoutParams lpVideo" + val_peek(4).sval + " = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n"+
    "\t\tlpVideo" + val_peek(4).sval + ".addRule(RelativeLayout.BELOW, autoID-2);\n" +
    "\t\t" + val_peek(4).sval + ".setLayoutParams(lpVideo" + val_peek(4).sval + ");\n\n" +
    "\t\tnudroidLayout.addView(" + val_peek(4).sval + ");\n" +    
    "\t\t" + val_peek(4).sval + ".start();\n" 
	;

/*
	String name = "mp" + $2.sval;
	$$.sval = "\t\tMediaPlayer " + name + " = new MediaPlayer();\n" +
	"\t\ttry {\n" +
    addName(name, $3.sval,3) + 
    "\t\t\t" + name + ".prepare();\n" +
    "\t\t\t" +name + ".start();\n" +
    "\t\t} catch (Exception e) {\n" +
		"\t\t\te.printStackTrace();\n" +
		"\t\t}\n\n";
    
    System.out.println("Video code:\n" + $$.sval);
*/
}
break;
case 68:
//#line 967 "nudroid.y"
{System.out.println("Empty video param"); yyval.sval = "";}
break;
case 69:
//#line 968 "nudroid.y"
{System.out.println("Recursive video param"); yyval.sval = val_peek(1).sval + val_peek(0).sval;}
break;
case 71:
//#line 972 "nudroid.y"
{System.out.println("URL"); yyval.sval = val_peek(0).sval;}
break;
case 72:
//#line 977 "nudroid.y"
{ 
 yyval.sval = "\n\t\t// " + val_peek(4).sval + "Button Creation\n" +
 "\t\tButton " + val_peek(4).sval + " = new Button(this);\n" +
 "\t\t" + val_peek(4).sval + ".setId(autoID++);\n" +
 "\t\t"+val_peek(4).sval+".setText(\"" + val_peek(3).sval + "\");\n" +
 
 "\t\tRelativeLayout.LayoutParams lp" + val_peek(4).sval + " = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);\n" +
 "lp" + val_peek(4).sval + ".addRule(RelativeLayout.BELOW, autoID-2);\n" +
 val_peek(4).sval + ".setLayoutParams(lp" + val_peek(4).sval + ");\n" + 
 
 "\t\tnudroidLayout.addView(" + val_peek(4).sval + ");\n" +
 "\t\t" + val_peek(4).sval + ".setOnClickListener(new View.OnClickListener() {\n" +
 "\t\t\tpublic void onClick(View v) {\n" +
 
 "\t\t\t\t" + val_peek(1).sval + "\n" +
 
 "\t\t\t}\n" +
 "\t\t});\n"
;}
break;
case 73:
//#line 1004 "nudroid.y"
{
	System.out.println("VARIABLE tag reduced.");
	
	if(SymbolTable.containsVariable(val_peek(2).sval))
	{
		System.err.println(val_peek(2).sval + " has already been initialized.");
	}
	else
	{
		System.out.println("ID = " + val_peek(2).sval);
		System.out.println("Value= " + val_peek(1).sval);
		/*temp = value; SymbolTable.setVar(id, temp);*/
		String tempVar = SymbolTable.tempVarName();
		yyval.sval = "int " + tempVar + "=" + val_peek(1).sval + ";\n" +
		"SymbolTable.addVar(\"" + val_peek(2).sval + "\", " + tempVar + ");\n";
		
		SymbolTable.initializeVariable(val_peek(2).sval);
		System.out.println("Initialized " + val_peek(2).sval);
		
		variableDeclarations = variableDeclarations + "\n" + yyval.sval; 
	}
}
break;
case 74:
//#line 1035 "nudroid.y"
{System.out.println("Value tag = " + val_peek(0).dval); yyval.sval = val_peek(0).sval; }
break;
case 75:
//#line 1050 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 76:
//#line 1051 "nudroid.y"
{yyval.sval = val_peek(1).sval + "\n" + val_peek(0).sval;}
break;
case 77:
//#line 1054 "nudroid.y"
{yyval.sval = "\"\"";}
break;
case 78:
//#line 1055 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 79:
//#line 1058 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 80:
//#line 1059 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 81:
//#line 1060 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 82:
//#line 1061 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 83:
//#line 1062 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 84:
//#line 1063 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 85:
//#line 1064 "nudroid.y"
{yyval.sval = val_peek(0).sval; System.out.println("Test:\n" + val_peek(0).sval);}
break;
case 86:
//#line 1065 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 87:
//#line 1069 "nudroid.y"
{
	yyval.sval = "\t\t startActivity(new Intent(thisPage," + val_peek(1).sval + ".class));\n";
}
break;
case 88:
//#line 1075 "nudroid.y"
{
	if(SymbolTable.containsVariable(val_peek(2).sval))
	{
		String tempVar = SymbolTable.tempVarName();
		yyval.sval = "int " + tempVar + "=" + val_peek(1).sval + ";\n" +
		"SymbolTable.setVar(\"" + val_peek(2).sval + "\", " + tempVar + ");\n";
		
		System.out.println("SetVar tag:\n" + yyval.sval);
	}
	else
	{
		System.err.println(val_peek(2).sval + " has not been initialized.");
	}
	
}
break;
case 89:
//#line 1093 "nudroid.y"
{
	if(SymbolTable.containsVariable(val_peek(1).sval))
	{
		/*turn value into string*/
		yyval.sval = " (\"\" + SymbolTable.getVar(\"" + val_peek(1).sval + "\"))";
	}
	else
	{
		System.err.println(val_peek(1).sval + " has not been initialized.");
	}
}
break;
case 90:
//#line 1107 "nudroid.y"
{
	if(SymbolTable.containsInput(val_peek(1).sval))
	{
		yyval.sval = val_peek(1).sval + ".getText()";
	}
	else
	{
		System.err.println("Input " + val_peek(1).sval + " has not been initialized.");
	}
}
break;
case 91:
//#line 1120 "nudroid.y"
{
	yyval.sval = val_peek(1).sval + ".getText()";
}
break;
case 92:
//#line 1126 "nudroid.y"
{
		yyval.sval = "\t\t" + val_peek(3).sval + ".setText(" + val_peek(1).sval + ");";
	}
break;
case 93:
//#line 1147 "nudroid.y"
{yyval.sval = "(" + val_peek(2).sval + "+" + val_peek(0).sval + ")";}
break;
case 94:
//#line 1148 "nudroid.y"
{yyval.sval = "(" + val_peek(2).sval + "-" + val_peek(0).sval + ")";}
break;
case 95:
//#line 1149 "nudroid.y"
{yyval.sval = val_peek(0).sval; System.out.println("term = " + val_peek(0).sval);}
break;
case 96:
//#line 1152 "nudroid.y"
{yyval.sval = "(" + val_peek(2).sval + "*" + val_peek(0).sval + ")";}
break;
case 97:
//#line 1153 "nudroid.y"
{yyval.sval = "(" + val_peek(2).sval + "/" + val_peek(0).sval + ")";}
break;
case 98:
//#line 1154 "nudroid.y"
{yyval.sval = val_peek(0).sval; System.out.println("factor = " + val_peek(0).sval);}
break;
case 99:
//#line 1157 "nudroid.y"
{yyval.sval = "(" + val_peek(1).sval + ")";}
break;
case 100:
//#line 1158 "nudroid.y"
{yyval.sval = val_peek(0).sval; System.out.println("num = " + val_peek(0).sval);}
break;
case 101:
//#line 1161 "nudroid.y"
{yyval.sval = "" + (int)val_peek(0).dval; System.out.println("Number: " + val_peek(0).dval);}
break;
case 102:
//#line 1163 "nudroid.y"
{
   			if(SymbolTable.containsVariable(val_peek(0).sval))
   			{
   				yyval.sval = "SymbolTable.getVar(\"" + val_peek(0).sval + "\")";
   			}
   			else
   			{
   				System.err.println(val_peek(0).sval + " has not been initialized.");
   			}
   		}
break;
case 104:
//#line 1175 "nudroid.y"
{
   			if(SymbolTable.containsVariable(val_peek(0).sval))
   			{
   				yyval.sval = "SymbolTable.getVar(\"" + val_peek(0).sval + "\")";
   			}
   			else if(SymbolTable.containsInput(val_peek(0).sval))
   			{
   				
   				yyval.sval = "(SymbolTable.safeParseInt(" +val_peek(0).sval + ".getText().toString()))";
   			}
   			else
   			{
   				System.err.println(val_peek(0).sval + " has not been initialized or is not a variable or input.");
   			}
   		}
break;
case 105:
//#line 1193 "nudroid.y"
{yyval.sval = "((" + val_peek(2).sval + ") || (" + val_peek(0).sval + "))";}
break;
case 106:
//#line 1194 "nudroid.y"
{yyval.sval = "((" + val_peek(2).sval + ") && (" + val_peek(0).sval + "))";}
break;
case 107:
//#line 1195 "nudroid.y"
{yyval.sval = "!(" + val_peek(0).sval + ")";}
break;
case 108:
//#line 1196 "nudroid.y"
{yyval.sval = "(" + val_peek(1).sval + ")";}
break;
case 109:
//#line 1197 "nudroid.y"
{yyval.sval = "(" + val_peek(2).sval + " " + val_peek(1).sval + " " + val_peek(0).sval + ")";}
break;
case 112:
//#line 1202 "nudroid.y"
{yyval.sval = "<";}
break;
case 113:
//#line 1203 "nudroid.y"
{yyval.sval = ">";}
break;
case 114:
//#line 1204 "nudroid.y"
{yyval.sval = "==";}
break;
case 115:
//#line 1205 "nudroid.y"
{yyval.sval = ">=";}
break;
case 116:
//#line 1206 "nudroid.y"
{yyval.sval = "<=";}
break;
case 117:
//#line 1207 "nudroid.y"
{yyval.sval = "!=";}
break;
case 118:
//#line 1212 "nudroid.y"
{
	String trueCode = val_peek(2).sval;
	if(trueCode.equals("\"\""))
		trueCode = "";
		
	String falseCode = val_peek(1).sval;
	if(falseCode.equals("\"\""))
		falseCode = "";
	
	yyval.sval = "if(" + val_peek(4).sval + ")\n" +
	"{\n" + trueCode + "}\n" +
	"else\n" +
	"{\n" + falseCode + "}\n";
}
break;
case 119:
//#line 1229 "nudroid.y"
{yyval.sval = val_peek(1).sval;}
break;
case 120:
//#line 1233 "nudroid.y"
{yyval.sval = val_peek(1).sval;}
break;
case 121:
//#line 1239 "nudroid.y"
{
	String loop_var = SymbolTable.tempVarName();
	String boundary = SymbolTable.tempVarName();
	
	yyval.sval = 	"int " + loop_var + "=" + val_peek(5).sval + ";\n" +
				"int " + boundary + "=" + val_peek(3).sval + ";\n" +
				"while(" + loop_var + " <= " + boundary + ")\n" +
				"{\n" +
				val_peek(1).sval + "\n" +
				loop_var + "++;\n" + /*increment loop variable*/
				"}\n";
				
}
break;
case 122:
//#line 1256 "nudroid.y"
{yyval.sval = val_peek(0).sval ;}
break;
case 123:
//#line 1259 "nudroid.y"
{yyval.sval = val_peek(0).sval ;}
break;
case 124:
//#line 1262 "nudroid.y"
{yyval.sval = val_peek(0).sval ;}
break;
case 125:
//#line 1265 "nudroid.y"
{yyval.sval = val_peek(0).sval ;}
break;
case 126:
//#line 1268 "nudroid.y"
{yyval.sval = val_peek(0).sval;}
break;
case 132:
//#line 1303 "nudroid.y"
{yyval.sval = "\"\"";}
break;
case 133:
//#line 1304 "nudroid.y"
{ yyval.sval = val_peek(1).sval + " + \"" + val_peek(0).sval + "\""; }
break;
case 135:
//#line 1306 "nudroid.y"
{yyval.sval = val_peek(1).sval + " + " + val_peek(0).sval;}
break;
case 136:
//#line 1307 "nudroid.y"
{yyval.sval = val_peek(1).sval + " + " + val_peek(0).sval;}
break;
case 137:
//#line 1308 "nudroid.y"
{yyval.sval = val_peek(1).sval + " + " + val_peek(0).sval;}
break;
case 138:
//#line 1311 "nudroid.y"
{yyval.sval = "\"\"";}
break;
case 139:
//#line 1312 "nudroid.y"
{yyval.sval = "\"" + val_peek(0).sval + "\"";}
break;
//#line 2099 "Parser.java"
//########## END OF USER-SUPPLIED ACTIONS ##########
    }//switch
    //#### Now let's reduce... ####
    if (yydebug) debug("reduce");
    state_drop(yym);             //we just reduced yylen states
    yystate = state_peek(0);     //get new state
    val_drop(yym);               //corresponding value drop
    yym = yylhs[yyn];            //select next TERMINAL(on lhs)
    if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL
      {
      if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+"");
      yystate = YYFINAL;         //explicitly say we're done
      state_push(YYFINAL);       //and save it
      val_push(yyval);           //also save the semantic value of parsing
      if (yychar < 0)            //we want another character?
        {
        yychar = yylex();        //get next character
        if (yychar<0) yychar=0;  //clean, if necessary
        if (yydebug)
          yylexdebug(yystate,yychar);
        }
      if (yychar == 0)          //Good exit (if lex returns 0 ;-)
         break;                 //quit the loop--all DONE
      }//if yystate
    else                        //else not done yet
      {                         //get next state and push, for next yydefred[]
      yyn = yygindex[yym];      //find out where to go
      if ((yyn != 0) && (yyn += yystate) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
        yystate = yytable[yyn]; //get new state
      else
        yystate = yydgoto[yym]; //else go to new defred
      if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+"");
      state_push(yystate);     //going again, so push state & val...
      val_push(yyval);         //for next action
      }
    }//main loop
  return 0;//yyaccept!!
}
//## end of method parse() ######################################



//## run() --- for Thread #######################################
/**
 * A default run method, used for operating this parser
 * object in the background.  It is intended for extending Thread
 * or implementing Runnable.  Turn off with -Jnorun .
 */
public void run()
{
  yyparse();
}
//## end of method run() ########################################



//## Constructors ###############################################
/**
 * Default constructor.  Turn off with -Jnoconstruct .

 */
public Parser()
{
  //nothing to do
}


/**
 * Create a parser, setting the debug to true or false.
 * @param debugMe true for debugging, false for no debug.
 */
public Parser(boolean debugMe)
{
  yydebug=debugMe;
}
//###############################################################



}
//################### END OF CLASS ##############################
